/**
 * Copyright (c) subnew
 * Licensed under the GPL;
 * @email:joseanluo@gmail.com
 * @Title: SysOperator.java
 * @Package com.subnew.copyman.modules.sys.entity
 */
package com.subnew.mango.modules.sys.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.subnew.mango.frame.dao.entity.BaseEntity;


/**
 * 系统管理员实体
 * 
 * @author JoseanLuo
 * @date 2014年9月14日 下午12:21:54
 * @version V1.0<br>
 *          V2.0 关联关系加入 20141223 
 */
@Entity
@Table(name = "sys_operator")
public class SysOperator extends BaseEntity {
	/**
	 * 登录名
	 */
	private String loginname;
	/**
	 * 用户姓名
	 */
	private String name;
	/**
	 * 密码
	 */
	private String pwd;
	/**
	 * 头像
	 */
	private String photo;
	/**
	 * 开始时间
	 */
	private Date stime;
	/**
	 * 结束时间
	 */
	private Date etime;
	/**
	 * 登陆次数
	 */
	private Integer logtimes;
	/**
	 * 最后登陆时间
	 */
	private Date lasttime;
	/**
	 * 用户所属组织
	 */
	private Set<SysGroup> sysGroups = new HashSet<SysGroup>(0);
	/**
	 * 用户所属角色
	 */
	private Set<SysRole> sysRoles = new HashSet<SysRole>(0);
	/**
	 * 用户详细信息
	 */
	private Set<SysOperatorInfo> sysOperatorinfos = new HashSet<SysOperatorInfo>(0);
	
	
	@Column(name = "loginname", length = 100)
	public String getLoginname() {
		return this.loginname;
	}

	public void setLoginname(String loginname) {
		this.loginname = loginname;
	}

	@Column(name = "name", length = 100)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "pwd", length = 100)
	public String getPwd() {
		return this.pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	@Column(name = "photo", length = 200)
	public String getPhoto() {
		return this.photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "stime", length = 19)
	public Date getStime() {
		return this.stime;
	}

	public void setStime(Date stime) {
		this.stime = stime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "etime", length = 19)
	public Date getEtime() {
		return this.etime;
	}

	public void setEtime(Date etime) {
		this.etime = etime;
	}

	@Column(name = "logtimes")
	public Integer getLogtimes() {
		return this.logtimes;
	}

	public void setLogtimes(Integer logtimes) {
		this.logtimes = logtimes;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "lasttime", length = 19)
	public Date getLasttime() {
		return this.lasttime;
	}

	public void setLasttime(Date lasttime) {
		this.lasttime = lasttime;
	}
	
	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "sys_operator_group",  joinColumns = { @JoinColumn(name = "operator_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "group_id", nullable = false, updatable = false) })
	public Set<SysGroup> getSysGroups() {
		return this.sysGroups;
	}

	public void setSysGroups(Set<SysGroup> sysGroups) {
		this.sysGroups = sysGroups;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysOperators")
	public Set<SysRole> getSysRoles() {
		return this.sysRoles;
	}

	public void setSysRoles(Set<SysRole> sysRoles) {
		this.sysRoles = sysRoles;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysOperator")
	public Set<SysOperatorInfo> getSysOperatorinfos() {
		return this.sysOperatorinfos;
	}

	public void setSysOperatorinfos(Set<SysOperatorInfo> sysOperatorinfos) {
		this.sysOperatorinfos = sysOperatorinfos;
	}
}
